import { CrowllerController, LoginController } from "../controller";

// 枚举类型
export enum Methods {
  get = "get",
  post = "post",
}
// 工厂模式返回 方法装饰器工厂函数
function getRequestDecorator(type: Methods) {
  return function post(path: string) {
    return function (
      target: CrowllerController | LoginController,
      key: string
    ) {
      Reflect.defineMetadata("path", path, target, key);
      Reflect.defineMetadata("method", type, target, key);
    };
  };
}
// 导出方法装饰器工厂函数（注意这里导出的不是装饰器）
export const get = getRequestDecorator(Methods.get);
export const post = getRequestDecorator(Methods.post);
